#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_QtOpenCvServer.h"
#include <QMouseEvent>
#include <QResizeEvent>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QTcpServer>
#include <QTcpSocket>
#include <QDateTime>
#include <QTimer>
#include <QFile>
#include <QDebug>
#include <opencv.hpp>
using namespace cv;
using namespace std;

class QtOpenCvServer : public QMainWindow
{
    Q_OBJECT

public:
    QtOpenCvServer(QWidget *parent = nullptr);
    ~QtOpenCvServer();
signals:
    void addEmployee();
private:
    Ui::QtOpenCvServerClass ui;
    //人脸识别支持
    QTcpServer *server;
    QTimer checkTimer;
    QPointF dragPosition;
    bool isDragging;
    cv::Mat testeddescriptors, descriptors;

private slots:
    void onNewConnection();
    void deleteLater(QTcpSocket* clientSocket);
    void onReadyRead(QTcpSocket* clientSocket);
    QString matchingFace(cv::Mat testedFaceData);
    vector<DMatch> ratioTest(std::vector<std::vector<cv::DMatch>>& knn_matches);
protected:
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
protected slots:
    void on_quitApp_clicked();
    void on_openServer_clicked();
    void on_addEmployees_clicked();
};
